# This file is part of Digidoc
#
# Digidoc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Digidoc Copyright (C) 2008 Paolo Alberti <paolo.alberti_at_gmail.com>

import datetime; now=datetime.date.today() 

# Definig Database
db=SQLDB('sqlite://digidoc.db')

# Defining tables
##db.define_table('scaffali',
##    SQLField('descrizione'))

db.define_table('faldoni',
    SQLField('descrizione'),
    SQLField('dtcreazione','date',requires=IS_DATE('%d/%m/%Y'),default=now))

db.define_table('carpette',
    SQLField('faldoni_id',db.faldoni),
    SQLField('descrizione'),
    SQLField('dtcreazione','date',requires=IS_DATE('%d/%m/%Y'),default=now))

db.define_table('fascicoli',
    SQLField('carpette_id',db.carpette),
    SQLField('descrizione'),
    SQLField('dtcreazione','date',requires=IS_DATE('%d/%m/%Y'),default=now))

db.define_table('documenti',
    SQLField('fascicoli_id',db.fascicoli),
    SQLField('descrizione'),
    SQLField('percorso'),
    SQLField('pchiave'),
    SQLField('dtarchiviazione','date',requires=IS_DATE('%d/%m/%Y'),default=now))


db.faldoni.represent=lambda faldone: A(db.id,_href=t2.action('display',faldoni.id))
db.carpette.represent=lambda carpetta: A(db.id,_href=t2.action('display',carpette.id))
db.fascicoli.represent=lambda fascicolo: A(db.id,_href=t2.action('display',fascicoli.id))
db.documenti.represent=lambda documento: A(db.id,_href=t2.action('display',documenti.id))
